package com.s3.s3demo.aws;

import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.ListObjectsRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsResponse;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;

import java.nio.file.Path;

/**
 * 上传文件到存储桶
 */
public class PutObjects extends AwsAuth {

    public static void main(String[] args) {
        try (S3Client s3Client = generateS3Client()) {
            s3Client.putObject(PutObjectRequest.builder().bucket("test0224").key("kestra").build(),
                    Path.of("F:\\s3test\\kestra.yaml"));
            ListObjectsResponse response = s3Client.listObjects(ListObjectsRequest.builder().bucket("test0224").prefix("kestra").build());
            response.contents().forEach(System.out::println);
        }
    }

}
